package com.ruoyi.training.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.training.domain.SystemField;
import com.ruoyi.training.service.ISystemFieldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 证书固定字段Controller
 * 
 * @author hcc
 * @date 2025-11-06
 */
@RestController
@RequestMapping("/systemField")
public class SystemFieldController extends BaseController
{
    @Autowired
    private ISystemFieldService systemFieldService;

    /**
     * 查询证书固定字段列表
     */
    @RequiresPermissions("training:systemField:list")
    @GetMapping("/list")
    public TableDataInfo list(SystemField systemField)
    {
        startPage();
        List<SystemField> list = systemFieldService.selectSystemFieldList(systemField);
        return getDataTable(list);
    }

    /**
     * 导出证书固定字段列表
     */
    @RequiresPermissions("training:systemField:export")
    @Log(title = "证书固定字段", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SystemField systemField)
    {
        List<SystemField> list = systemFieldService.selectSystemFieldList(systemField);
        ExcelUtil<SystemField> util = new ExcelUtil<SystemField>(SystemField.class);
        util.exportExcel(response, list, "证书固定字段数据");
    }

    /**
     * 获取证书固定字段详细信息
     */
    @RequiresPermissions("training:systemField:query")
    @GetMapping(value = "/{sysytemFieldId}")
    public AjaxResult getInfo(@PathVariable("sysytemFieldId") String sysytemFieldId)
    {
        return success(systemFieldService.selectSystemFieldBySysytemFieldId(sysytemFieldId));
    }

    /**
     * 新增证书固定字段
     */
    @RequiresPermissions("training:systemField:add")
    @Log(title = "证书固定字段", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SystemField systemField)
    {
        return toAjax(systemFieldService.insertSystemField(systemField));
    }

    /**
     * 修改证书固定字段
     */
    @RequiresPermissions("training:systemField:edit")
    @Log(title = "证书固定字段", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SystemField systemField)
    {
        return toAjax(systemFieldService.updateSystemField(systemField));
    }

    /**
     * 删除证书固定字段
     */
    @RequiresPermissions("training:systemField:remove")
    @Log(title = "证书固定字段", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sysytemFieldIds}")
    public AjaxResult remove(@PathVariable String[] sysytemFieldIds)
    {
        return toAjax(systemFieldService.deleteSystemFieldBySysytemFieldIds(sysytemFieldIds));
    }
}
